package com.learn.jdk;

import java.util.Arrays;
import java.util.List;

/**
 * Copyright: Copyright (c) 2019 Asiainfo
 *
 * @ClassName: com.learn.jdk.StringComparator
 * @Description: 该类的功能描述
 * @version: v1.0.0
 * @author: lipan
 * @date: 2019/10/20 15:42
 * <p>
 * Modification History:
 * Date         Author          Version            Description
 * ------------------------------------------------------------
 * 2019/10/20      lipan          v1.0.0               修改原因
 */

public class StringComparator {

    public static void main(String[] args) {

        List<String> names = Arrays.asList("tom", "jack", "uzi", "aaaa");

//        names.sort((str1,str2)->str1.compareTo(str2));//用了string类自自己实现的排序规则

        //自定义排序规则
        names.sort((str1,str2)->str1.length()-str2.length());

        System.out.println(names);

    }

}
